import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:meal/components/product/edit_set_meal.dart';
import 'package:meal/components/product/edit_single_item.dart';
import 'package:meal/model/product.dart';
import 'package:meal/utils/tools.dart';

///
/// 编辑商品
///
class ProductEdit extends StatefulWidget {
  const ProductEdit({Key? key}) : super(key: key);

  @override
  State<ProductEdit> createState() => _ProductEditState();
}

class _ProductEditState extends State<ProductEdit> {
  late ProductModel product;

  @override
  void initState() {
    super.initState();
    product = Get.arguments as ProductModel;
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: ToolsUtils.getDefaultBackgroundColor(),
      appBar: ToolsUtils.getDefaultBrnAppBar('编辑商品',
          actions: ToolsUtils.actions('保存', pressed: () {
            Get.back();
          })),
      body: SingleChildScrollView(
        child: product.meal ? EditSetMeal(product: product) : EditSingleItem(product: product),
      ),
    );
  }
}
